package datastructure;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class SuffixTreeNode {
	private List<String> owners;
	private String value;
	private SuffixTreeNode parent;
	private List<SuffixTreeNode> childNodes;

	
	public SuffixTreeNode(String value,SuffixTreeNode parent){
		this.value = value;
		this.parent = parent;
		this.owners = new ArrayList<String>();
		this.childNodes = new LinkedList<SuffixTreeNode>();
	}
	
	public void addChildNode(SuffixTreeNode node){
		childNodes.add(node);
	}
	
	public List<SuffixTreeNode> getChildNodes(){
		return Collections.unmodifiableList(childNodes);
	}
	
	public void removeChildNode(SuffixTreeNode node){
		Iterator<SuffixTreeNode> iter = childNodes.iterator();
		while(iter.hasNext()){
			SuffixTreeNode toRemove = iter.next();
			if(toRemove.equals(node)){
				iter.remove();
			}
		}
	}
	
	public String getValue(){
		return value;
	}
	
	public void addOwner(String owner){
		owners.add(owner);
	}
	
	public List<String> getOwners(){
		return Collections.unmodifiableList(owners);
	}
	
	public SuffixTreeNode getParent(){
		return parent;
	}
	
}
